
/********************* Common **********************/
const commonUtil = {
    notice(context, msg='这是一条消息提示', type='success', time=3) {
      context.$message({
        message: msg,
        type: type,
        duration: time * 1000,
        customClass: 'zZindex'
      });
    }
  }
/********************* Cookie **********************/
//设置cookie
function setCookie(cname,cvalue,exdays)
{
var d = new Date();
d.setTime(d.getTime()+(exdays*24*60*60*1000));
var expires = "expires="+d.toGMTString();
document.cookie = cname + "=" + cvalue + "; " + expires;
}
//获取cookie
function getCookie(cname)
{
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) 
{
    var c = ca[i].trim();
    if (c.indexOf(name)==0) return c.substring(name.length,c.length);
}
return "";
}
function clearCookie(name) {  
setCookie(name, "", -1);  
} 
function getCookie2(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
//console.log("获取cookie,现在循环")
for (var i = 0; i < ca.length; i++) {
    var c = ca[i];
    //console.log(c)
    while (c.charAt(0) == ' ') c = c.substring(1);
    if (c.indexOf(name) != -1){
    return c.substring(name.length, c.length);
    }
}
return "";
}

//检查cookie
function checkCookie()
{
var user=getCookie("username");
if (user!="")
{
    alert("Welcome again " + user);
}
else 
{
    user = prompt("Please enter your name:","");
    if (user!="" && user!=null)
    {
    setCookie("username",user,365);
    }
}
}
/*************************** Common util **************************/
function isArray(obj) {
    return typeof obj == 'object' && obj.constructor == Array
}

function deepCopy (obj) {
    return JSON.parse(JSON.stringify(obj))
}


const utils = {
    common: commonUtil,
    isArray,
    deepCopy: deepCopy,
    
}


